import React, { PureComponent } from 'react'
// import { connect } from "react-redux"
import { myConnect } from "../hoc/connect"
import { addNumberAction } from '../store/features/counter/actionCreators'

export class About extends PureComponent {

  calcNumber(num, isAdd){
    this.props.addNumber(num)
  }

  render() {
    const { counter } = this.props
    return (
      <div>
        <h2>这是about页面 counter: {counter}</h2>
        <div>
          <button onClick={e => this.calcNumber(6, true)}>+6</button>
        </div> 
         
      </div>
    )
  }
}

const mapStateToProps = (state) => ({
  counter: state.mycounter.counter,
})

const mapDispatchToProps = (dispatch) => ({
  addNumber(num) {
    dispatch(addNumberAction(num))
  }
})

export default myConnect(mapStateToProps, mapDispatchToProps)(About)